package com.hbsx.why.ui;

import android.widget.TextView;

import com.hbsx.why.R;
import com.hbsx.why.base.BaseActivity;
import com.hbsx.why.utils.refresh.PullScrollView;
import com.hbsx.why.utils.refresh.PullToRefreshLayout;

import butterknife.BindView;

/**
 * Created by liub on 2017/7/31 09:49.
 */

public class DemoPushMessage extends BaseActivity {
    @BindView(R.id.tv_topTitle)
    TextView tvTopTitle;
    @BindView(R.id.demo_main_scrollview)
    PullScrollView demoMainScrollview;
    @BindView(R.id.pullToRefreshLayout)
    PullToRefreshLayout mpullToRefreshLayout;

    @Override
    protected int getLayoutResId() {
        return R.layout.demo_push_message;
    }

    @Override
    protected void initView() {
        tvTopTitle.setText("推送消息");

        demoMainScrollview.setPullDownEnable(true);
        demoMainScrollview.setPullUpEnable(true);
        demoMainScrollview.canPullUp();
        demoMainScrollview.canPullDown();
        mpullToRefreshLayout.setOnRefreshListener(new PullToRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh(PullToRefreshLayout pullToRefreshLayout) {
                pullToRefreshLayout.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        mpullToRefreshLayout.refreshFinish(true);
                        toast_short("onRefresh");
                    }
                }, 1000); // (x/1000)秒后刷新

            }

            @Override
            public void onLoadMore(PullToRefreshLayout pullToRefreshLayout) {
                mpullToRefreshLayout.loadMoreFinish(true);
                toast_short("onLoadMore");
            }
        });
    }
}
